--
-- CS488 -- Introduction to Computer Graphics
-- 
-- puppet.lua

red = gr.material({1.0, 0.0, 0.0}, {0.1, 0.1, 0.1}, 10, 0.0)
blue = gr.material({0.0, 1.0, 1.0}, {0.1, 0.1, 0.1}, 10, 0.0)
white = gr.material({1.0, 1.0, 1.0}, {0.1, 0.1, 0.1}, 10, 0.0)
yellow = gr.material({1.0, 1.0, 0.0}, {0.1, 0.1, 0.1}, 10, 0.0)

puppet = gr.joint('puppet', {-20.0, 0.0, 10.0}, {0.0, 0.0, 0.0})
scene:add_child(puppet)

-- Body
Body = gr.sphere('PBody')
puppet:add_child(Body)
Body:scale(2.0, 2.0, 1.2)
Body:set_material(white)

-- Heart
Heart = gr.sphere('PHeart')
puppet:add_child(Heart)
Heart:scale(0.3, 0.3, 0.3)
Heart:translate(0.0, 4.0, 4.0)
Heart:set_material(blue)

-- Shoulders
Shoulders = gr.sphere('PShoulders')
puppet:add_child(Shoulders)
Shoulders:scale(3.0, 1.2, 1.2)
Shoulders:translate(0.0, 1.0, 0.0)
Shoulders:set_material(red)

-- Hips
Hips = gr.sphere('PHips')
puppet:add_child(Hips)
Hips:scale(2.0, 1.2, 1.2)
Hips:translate(0.0, -0.8, 0.0)
Hips:set_material(red)

-- Joint-Neck
Joint_Neck = gr.joint('JNeck', {-20.0, 0.0, 10.0}, {0.0, 0.0, 0.0})
puppet:add_child(Joint_Neck)
Joint_Neck:translate(0.0, 2.4, 0.0)

-- Neck
Neck = gr.sphere('PNeck')
Joint_Neck:add_child(Neck)
Neck:scale(0.7, 0.8, 0.7)
Neck:set_material(white)

-- Joint-Head
Joint_Head = gr.joint('JHead',{-20.0, 0.0, 20.0},{-70.0, 0.0, 70.0})
Joint_Neck:add_child(Joint_Head)
Joint_Head:translate(0.0, 1.8, 0.0)

-- Head
Head = gr.sphere('PHead')
Joint_Head:add_child(Head)
Head:scale(1.8, 1.8, 1.8)
Head:set_material(white)

-- Hat
Hat = gr.sphere('PHat')
Joint_Head:add_child(Hat)
Hat:scale(0.3, 1.7, 1.7)
Hat:translate(0.0, 0.4, 0.0)
Hat:set_material(white)

-- LeftEye
LeftEye = gr.sphere('PLeftEye')
Joint_Head:add_child(LeftEye)
LeftEye:scale(0.7, 0.7, 0.6)
LeftEye:translate(0.8, -0.3, 2.2)
LeftEye:set_material(yellow)

-- RightEye
RightEye = gr.sphere('PRightEye')
Joint_Head:add_child(RightEye)
RightEye:scale(0.7, 0.7, 0.6)
RightEye:translate(-0.8, -0.3, 2.2)
RightEye:set_material(yellow)

-------------------------------- Left Hand
-- Joint-LeftUpperArm
Joint_LeftUpperArm = gr.joint('JLeftUpperArm',{-180.0, 0.0, 90.0},{0.0, 0.0, 0.0})
puppet:add_child(Joint_LeftUpperArm)
Joint_LeftUpperArm:translate(2.7, 1.0, 0.0)

-- LUA
LUA = gr.sphere("LUA")
Joint_LeftUpperArm:add_child(LUA)
LUA:scale(1.0, 1.0, 1.0)
LUA:set_material(white)

-- LeftUpperArm
LeftUpperArm = gr.sphere('PLeftUpperArm')
Joint_LeftUpperArm:add_child(LeftUpperArm)
LeftUpperArm:scale(0.85, 1.1, 0.85)
LeftUpperArm:translate(0.0, -1.1, 0.0)
LeftUpperArm:set_material(red)

-- Joint-LeftForeArm
Joint_LeftForeArm = gr.joint('JLeftForeArm',{-120.0, 0.0, 0.0},{0.0, 0.0, 0.0})
Joint_LeftUpperArm:add_child(Joint_LeftForeArm)
Joint_LeftForeArm:translate(0.0, -2.0, 0.0)

-- LFA
LFA = gr.sphere("LFA")
Joint_LeftForeArm:add_child(LFA)
LFA:scale(0.75, 0.75, 0.75)
LFA:set_material(white)

-- LeftForeArm
LeftForeArm = gr.sphere('PLeftForeArm')
Joint_LeftForeArm:add_child(LeftForeArm)
LeftForeArm:scale(0.75, 1.2, 0.75)
LeftForeArm:translate(0.0, -0.5, 0.0)
LeftForeArm:set_material(red)

-- Joint-LeftHand
Joint_LeftHand = gr.joint('JLeftHand',{-30.0, 0.0, 30.0},{0.0, 0.0, 0.0})
Joint_LeftForeArm:add_child(Joint_LeftHand)
Joint_LeftHand:translate(0.0, -1.5, 0.0)

-- LeftHand
LeftHand = gr.sphere('PLeftHand')
Joint_LeftHand:add_child(LeftHand)
LeftHand:scale(0.8, 0.8, 0.8);
LeftHand:set_material(white)

-- LeftHand1
LeftHand1 = gr.sphere('PLeftHand1')
Joint_LeftHand:add_child(LeftHand1)
LeftHand1:scale(0.81, 0.5, 0.81)
LeftHand1:set_material(blue)

-------------------------------- Right Hand
-- Joint-RightUpperArm
Joint_RightUpperArm = gr.joint('JRightUpperArm',{-180.0, 0.0, 90.0},{0.0, 0.0, 0.0})
puppet:add_child(Joint_RightUpperArm)
Joint_RightUpperArm:translate(-2.7, 1.0, 0.0)

-- RUA

RUA = gr.sphere("RUA")
Joint_RightUpperArm:add_child(RUA)
RUA:scale(1.0, 1.0, 1.0)
RUA:set_material(white)

-- RightUpperArm
RightUpperArm = gr.sphere('PRightUpperArm')
Joint_RightUpperArm:add_child(RightUpperArm)
RightUpperArm:scale(0.85, 1.1, 0.85)
RightUpperArm:translate(0.0, -1.1, 0.0)
RightUpperArm:set_material(red)

-- Joint-RightForeArm
Joint_RightForeArm = gr.joint('JRightForeArm',{-120.0, 0.0, 0.0},{0.0, 0.0, 0.0})
Joint_RightUpperArm:add_child(Joint_RightForeArm)
Joint_RightForeArm:translate(0.0, -2.0, 0.0)

-- RFA
RFA = gr.sphere("RFA")
Joint_RightForeArm:add_child(RFA)
RFA:scale(0.75, 0.75, 0.75)
RFA:set_material(white)

-- RightForeArm
RightForeArm = gr.sphere('PRightForeArm')
Joint_RightForeArm:add_child(RightForeArm)
RightForeArm:scale(0.75, 1.2, 0.75)
RightForeArm:translate(0.0, -0.5, 0.0)
RightForeArm:set_material(red)

-- Joint-RightHand
Joint_RightHand = gr.joint('JRightHand',{-30.0, 0.0, 30.0},{0.0, 0.0, 0.0})
Joint_RightForeArm:add_child(Joint_RightHand)
Joint_RightHand:translate(0.0, -1.5, 0.0)

-- RightHand
RightHand = gr.sphere('PRightHand')
Joint_RightHand:add_child(RightHand)
RightHand:scale(0.8, 0.8, 0.8)
RightHand:set_material(white)

-- RightHand1
RightHand1 = gr.sphere('PRightHand1')
Joint_RightHand:add_child(RightHand1)
RightHand1:scale(0.81, 0.5, 0.81)
RightHand1:set_material(blue)

-------------------------------- Left Leg
-- Joint-LeftThigh
Joint_LeftThigh = gr.joint('JLeftThigh',{-90.0, 0.0, 30.0},{0.0, 0.0, 0.0})
puppet:add_child(Joint_LeftThigh)
Joint_LeftThigh:translate(1.0, -2.5, 0.0)

-- LeftThigh
LeftThigh = gr.sphere('PLeftThigh')
Joint_LeftThigh:add_child(LeftThigh)
LeftThigh:scale(1.1, 1.7, 1.1)
LeftThigh:set_material(red)

-- Joint-LeftCalf
Joint_LeftCalf = gr.joint('JLeftCalf',{0.0, 0.0, 90.0},{0.0, 0.0, 0.0})
Joint_LeftThigh:add_child(Joint_LeftCalf)
Joint_LeftCalf:translate(0.0, -1.6, 0.0)

-- LC
LC = gr.sphere('LC')
Joint_LeftCalf:add_child(LC)
LC:scale(0.9, 0.9, 0.9)
LC:set_material(white)

-- LeftCalf
LeftCalf = gr.sphere('PLeftCalf')
Joint_LeftCalf:add_child(LeftCalf)
LeftCalf:scale(0.85, 2.0, 0.85)
LeftCalf:translate(0.0, -0.8, 0.0)
LeftCalf:set_material(red)

-- Joint-LeftFoot
Joint_LeftFoot = gr.joint('JLeftFoot',{-20.0, 0.0, 30.0},{0.0, 0.0, 0.0})
Joint_LeftCalf:add_child(Joint_LeftFoot)
Joint_LeftFoot:translate(0.0, -3.0, 0.3)

-- LeftFoot
LeftFoot = gr.sphere('PLeftFoot')
Joint_LeftFoot:add_child(LeftFoot)
LeftFoot:scale(0.8, 0.7, 1.2)
LeftFoot:set_material(white)

------------------------------- Right Leg
-- Joint-RightThigh
Joint_RightThigh = gr.joint('JRightThigh',{-90.0, 0.0, 30.0},{0.0, 0.0, 0.0})
puppet:add_child(Joint_RightThigh)
Joint_RightThigh:translate(-1.0, -2.5, 0.0)

-- RightThigh
RightThigh = gr.sphere('PRightThigh')
Joint_RightThigh:add_child(RightThigh)
RightThigh:scale(1.1, 1.7, 1.1)
RightThigh:set_material(red)

-- Joint-RightCalf
Joint_RightCalf = gr.joint('JRightCalf',{0.0, 0.0, 90.0},{0.0, 0.0, 0.0})
Joint_RightThigh:add_child(Joint_RightCalf)
Joint_RightCalf:translate(0.0, -1.6, 0.0)

-- RC
RC = gr.sphere('RC')
Joint_RightCalf:add_child(RC)
RC:scale(0.9, 0.9, 0.9)
RC:set_material(white)

-- RightCalf
RightCalf = gr.sphere('PRightCalf')
Joint_RightCalf:add_child(RightCalf)
RightCalf:scale(0.85, 2.0, 0.85)
RightCalf:translate(0.0, -0.8, 0.0)
RightCalf:set_material(red)

-- Joint-RightFoot
Joint_RightFoot = gr.joint('JRightFoot',{-20.0, 0.0, 30.0},{0.0, 0.0, 0.0})
Joint_RightCalf:add_child(Joint_RightFoot)
Joint_RightFoot:translate(0.0, -3.0, 0.3)

-- RightFoot
RightFoot = gr.sphere('PRightFoot')
Joint_RightFoot:add_child(RightFoot)
RightFoot:scale(0.8, 0.7, 1.2)
RightFoot:set_material(white)


